<?php

$section = "login";

$titre = _LB_LOGIN;
$smarty->assign("titre", $titre);

//$act = Request::getIntNumber('act');
$email = Request::get('email');
$act = Request::get('act');

$smarty = DRX::load("smarty");
$smarty->assign("backlink",Session::getBackLink($section));

if ($act == SEND_LINK)
{
	if ($email != '' || isset($_POST['email']))
	{
		$login = new Login();
		$login->EMAIL = $email;
		$login->DISABLED = 0;

		if ($login->find(1))
		{
			$smarty->display('redirect_password.html');
		}
		else
		{
			$smarty->assign('result', _LB_MAIL_NOT_FOUND);
			$smarty->display('lost_password.html');
		}
	}
}
else if ($act == CHANGE_PASSWORD)
{
	$id = Request::getIntNumber('user_id');
	$code = Request::get('code');

	$login = new Login();
	$login->ID = $id;

	$login->ACTIVATION_CODE = $code;
	$login->find();
	if ($login->find(1))
	{
		$login->changePassword();
	}
	else
	{
		$smarty->assign('message', _LB_MAIL_NOT_FOUND);
	}

	$smarty->display('redirect_password.html');
}
else
{
	$smarty->display('lost_password.html');
}